package com.common.app.widget

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.viewpager.widget.ViewPager

/**
 * @author sosou
 * @description: 解决photoView图片缩放与viewPager触摸事件冲突产生的bug
 * 解决参考：https://blog.csdn.net/nnmmbb/article/details/28419779
 * @date 2022/9/1
 */
class ViewPagerCatchError @JvmOverloads constructor(context: Context, attrs:AttributeSet?) : ViewPager(context, attrs) {

    override fun onTouchEvent(ev: MotionEvent?): Boolean {
        try {
            return super.onTouchEvent(ev)
        } catch (ex: IllegalArgumentException) {
            ex.printStackTrace()
        }
        return false
    }

    override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
        try {
            return super.onInterceptTouchEvent(ev)
        } catch (ex: IllegalArgumentException) {
            ex.printStackTrace()
        }
        return false
    }

}